from publie.tools import *
from publie.action import *
from publie.testDATE import *

from selenium.webdriver.common.keys import Keys

testCase="DBshop013_商品分类编辑"

firefox=openB(adminurl)
adminlogin(firefox)
menuu3(firefox,"商品管理","管理分类","商品分类")
# "1.点击添加分类按钮，分类名称“商品分类测试”,分类排序输入1。
firefox.find_element_by_partial_link_text("添加分类").click()
firefox.find_element_by_id("class_name").clear()
firefox.find_element_by_id("class_name").send_keys(classname)

# 2.点击“保存分类”按钮”。
firefox.find_element_by_xpath("//button").click()
# 3.点击“商品分类测试”后方的分类编辑链接,进入商品分类编辑页面
firefox.find_element_by_xpath("//tr/td[contains(.,'%s')]/following-sibling::td[4]/a[2]"%classname).click()
# 4.将""商品分类测试""的分类排序修改为4,点击保存分类按钮"
firefox.find_element_by_id("class_sort").clear()
firefox.find_element_by_id("class_sort").send_keys("4")
firefox.find_element_by_xpath("//button[text()=' 保存分类']").click()

yuqi=4
#断言
actual=firefox.find_element_by_xpath('//td[contains(.,"%s")]/following-sibling::td[2]/input'%(classname)).get_property("value")
print(actual)
time.sleep(4)
if yuqi==int(actual):
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()
